package com.mxdx.edu.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.mxdx.edu.dao.SchoolStatusDao;
import com.mxdx.edu.model.SchoolStatusInfo;
import com.mxdx.edu.service.ISchoolStatusService;

/**
 * 专业信息service
 *
 * @author howie
 */
@Service
public class SchoolStatusServiceImpl implements ISchoolStatusService {

	@Resource
	private SchoolStatusDao schoolStatusDao;

	@Override
	public List<Map<String, Object>> findListByMap(Map<String, Object> param) {
		return schoolStatusDao.findListByMap(param);
	}

	@Override
	public boolean mergeSchoolStatus(Map<String, Object> map) {
		map.put("updateDate", new Date());
		return schoolStatusDao.updateByMap(map) > 0;
	}

	@Override
	public SchoolStatusInfo getByStudentId(String studentId) {
		Map<String, Object> map = new HashMap<>();
		map.put("studentId", studentId);
		SchoolStatusInfo schoolStatusInfo = null;
		List<Map<String, Object>> listMap = schoolStatusDao.findListByMap(map);
		if (listMap != null && !listMap.isEmpty()) {
			Map<String, Object> ss = listMap.get(0);
			JSONObject json =(JSONObject) JSONObject.toJSON(ss);
			schoolStatusInfo = JSONObject.toJavaObject(json, SchoolStatusInfo.class);
		}
		return schoolStatusInfo;
	}

	@Override
	public boolean updateSchoolStatus(Map<String, Object> param) {
		return schoolStatusDao.updateByMap(param) > 0;
		
	}

	@Override
	public Map<String, Object> findSchoolMapByMap(Map<String, Object> param) {
		return schoolStatusDao.findSchoolMapByMap(param);
	}
}
